﻿@{
    TagBuilder tag = Tag(Model, "li");

    // Morphing the shape to keep Model untouched
    Model.Metadata.Alternates.Clear();
    Model.Metadata.Type = "MenuItemLink";

    tag.InnerHtml.AppendHtml(await DisplayAsync(Model));

    if ((bool)Model.HasItems)
    {
        tag.InnerHtml.AppendHtml("<ul>");

        foreach (var item in Model.Items)
        {
            tag.InnerHtml.AppendHtml(await DisplayAsync(item));
        }

        tag.InnerHtml.AppendHtml("</ul>");
    }
}

@tag